#ifndef __STD_ERR_H__
#define __STD_ERR_H__

#include <esp_err.h>
#include "stdc.h"

#ifdef __cplusplus
extern "C" {
#endif


/// 标准错误码
typedef int std_err_t;
#define STD_ERR_OK                ESP_OK    				/*!< esp_err_t value indicating success (no error) */
#define STD_ERR_FAIL              ESP_FAIL    				/*!< Generic esp_err_t code indicating failure */

#define STD_ERR_NO_MEM            ESP_ERR_NO_MEM    		/*!< Out of memory */
#define STD_ERR_INVALID_ARG       ESP_ERR_INVALID_ARG    	/*!< Invalid argument */
#define STD_ERR_INVALID_STATE     ESP_ERR_INVALID_STATE    	/*!< Invalid state */
#define STD_ERR_INVALID_SIZE      ESP_ERR_INVALID_SIZE    	/*!< Invalid size */
#define STD_ERR_NOT_FOUND         ESP_ERR_NOT_FOUND    		/*!< Requested resource not found */
#define STD_ERR_NOT_SUPPORTED     ESP_ERR_NOT_SUPPORTED    	/*!< Operation or feature not supported */
#define STD_ERR_TIMEOUT           ESP_ERR_TIMEOUT    		/*!< Operation timed out */
#define STD_ERR_INVALID_RESPONSE  ESP_ERR_INVALID_RESPONSE  /*!< Received response was invalid */
#define STD_ERR_INVALID_CRC       ESP_ERR_INVALID_CRC   	/*!< CRC or checksum was invalid */
#define STD_ERR_INVALID_VERSION   ESP_ERR_INVALID_VERSION   /*!< Version was invalid */
#define STD_ERR_INVALID_MAC       ESP_ERR_INVALID_MAC   	/*!< MAC address was invalid */

#define STD_ERR_INVALID_IF_TYPE   -13   /*!< Interface type was invalid */
#define STD_ERR_INVALID_SRC_ADDR  -14   /*!< Source address was invalid */
#define STD_ERR_INVALID_DST_ADDR  -15   /*!< Destination address was invalid */
#define STD_ERR_INVALID_FRAME_LEN -16   /*!< Invalid frame length */
#define STD_ERR_INVALID_PARAM_LEN -17   /*!< Invalid parameter length */
#define STD_ERR_BUFFER_OVERFLOW   -18   /*!< Buffer overflow */
#define STD_ERR_BUFFER_UNDERFLOW  -19   /*!< Buffer underflow */
#define STD_ERR_INVALID_COMMAND   -20   /*!< Invalid command */


#define std_err_to_name(err) esp_err_to_name(err)

#define std_err_to_name_r(err, buf, buflen) esp_err_to_name_r(err, buf, buflen)


#ifdef __cplusplus
}
#endif

#endif // __STD_ERR_H__
